.\"
.\" This file and its contents are supplied under the terms of the
.\" Common Development and Distribution License ("CDDL"), version 1.0.
.\" You may only use this file in accordance with the terms of version
.\" 1.0 of the CDDL.
.\"
.\" A full copy of the text of the CDDL should have accompanied this
.\" source.  A copy of the CDDL is also available via the Internet at
.\" http://www.illumos.org/license/CDDL.
.\"
.\"
.\" Copyright 2014 Ryan Zezeski
.\" Copyright 2015 Joyent, Inc.
.\"
.Dd Apr 21, 2015
.Dt DATAFILT 4M
.Os
.Sh NAME
.Nm datafilt
.Nd socket filter module for deferred TCP connections
.Sh DESCRIPTION
The
.Nm datafilt
socket filter provides deferment of
.Xr accept 3SOCKET
for TCP connections.
The accept call will not return until at least one byte has been
buffered by the kernel.
Deferment assures the application that the first call to
.Xr read 2
or
.Xr recv 3SOCKET
will not block.
It reduces unnecessary switching between user and kernel.
.Sh EXAMPLES
.Ss Example 1
Enable deferment on the listening socket.
.Bd -literal
    setsockopt(lsock, SOL_FILTER, FIL_ATTACH, "datafilt", 8);
.Ed
.Ss Example 2
Disable deferment on the listening socket.
.Bd -literal
    char filt[] = "datafilt";
    setsockopt(lsock, SOL_FILTER, FIL_DETACH, filt, strlen(filt) + 1);
.Ed
.Sh SEE ALSO
.Xr setsockopt 3SOCKET
